package dxn.nl.file.api.export;

import dxn.nl.file.client.core.CsExportDealServer;
import dxn.nl.file.client.core.DealExportService;
import dxn.nl.file.client.core.SteamQueryCallBackService;
import dxn.nl.file.client.model.dto.*;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Component
@CsExportDealServer(value = {"demo_export_stream_no_title"})
public class DealStreamExportNoTitle implements DealExportService {
    @Override
    public CsExportDealTypeHeadDto getExcelHeads(TransferMessageConfig config, TransferMessageData messageData, byte[] data) {
        List<CsExportExcelHeadDto> dtoList = Arrays.asList();
        CsExportDealTypeHeadDto dto = CsExportDealTypeHeadDto.streamDeal(dtoList);
        return dto;
    }

    @Override
    public String streamQueryData(TransferMessageConfig config, TransferMessageData messageData, byte[] data, SteamQueryCallBackService steamQueryCallBackService){

        List<List<String>> list = new ArrayList<>();
        list.add(Arrays.asList("ceshi1","ceshi2"));
        list.add(Arrays.asList("航1","航2","航3"));
        list.add(Arrays.asList("尾部1"));

        // 流式导出，回调时必须指定sheet名称
        steamQueryCallBackService.handleResult(CsExportDealTypeHeadDto.defaultSheetName,list);
        return null;
    }
}
